const mysql = require('mysql')

const { MYSQL_CONFIG } = require('../../config/mysql')

const connection = mysql.createPool(MYSQL_CONFIG)


// const connection = mysql.createConnection(MYSQL_CONFIG)
// connection.connect();


function execSQL(sql, data){
    return new Promise((resolve,reject)=>{
        connection.query(sql, data, (error,result) => {
            if(error){
                reject(error);
            }else{
                resolve(result);
            }
        })
    })
}

module.exports = {
    execSQL,
    connection
}
